/*
 * 展示物料预定交易
 * 参数   交易码：trancode=42120
 */

package org.ccams.tran;


import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import net.sf.json.JSONObject;

import org.ccams.domain.TPlaninhead;
import org.ccams.util.Utils;
import org.ccams.web.UserSession;

public class Tran42125 extends AbstractJsonTran {

	@SuppressWarnings("unchecked")
	public void buildJSONObject(Map model, JSONObject json,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		int id = Integer.parseInt(request.getParameter("id"));
		HashMap<String, Object> jsonMap = new HashMap<String, Object>();
		boolean success = false;
		String message = "";
		int i =0;
		HttpSession session = request.getSession();
		UserSession userSession = (UserSession)session.getAttribute("userSession");
		TPlaninhead tp = new TPlaninhead();
		tp.setId(id);
		tp.setAdate(Utils.getCurrentDateTime());
		tp.setApid(userSession.getUser().getId());
		tp.setCwflag(1);
		i = getCcamsService().getTplaninheadDao().updateByPrimaryKey(tp);
		if (i == 1) {
			success = true;
			message = "物料采购审核成功";
		} else {
			success = false;
			message = "物料采购审核失败";
		}
		jsonMap.put("success", success);
		jsonMap.put("message", message);
		json.putAll(jsonMap);
	}
}
